
/******************************************************************************\
|    Title:        	 FIGUREF7: Robustness of the effect of switching on becoming|
|					 a lobbiyst												   |
|    Date:         	 July 2023	                                         	   |
|    Author:         Elisa Wirsching	      							       |
\******************************************************************************/


clear all
set more off, permanently
numlabel, add
set maxvar 32000


use congress_yearly.dta, clear
xtset stafferid year

*------------------------------------------------------------------------------*
* 								Leaving for other reasons					   *
*------------------------------------------------------------------------------*


xtreg lastyear switchtouncovered_treatment daysworked experience_imp experience_sq committeestaff_everyear personalstaff_everyear senate_everyear majority_everyear minority_everyear dcoffice_everyear leaderofficestaff_everyear i.year if posttreat==1 & lobbydirectafter==0, fe cluster(stafferid)

est store modelrob1


*------------------------------------------------------------------------------*
* 							Dropping those leaving in January				   *
*------------------------------------------------------------------------------*

* Januar is an indicator for whether a staffer left before January2 in a year
xtreg lobbydirectafter switchtouncovered_treatment daysworked experience_imp experience_sq committeestaff_everyear personalstaff_everyear senate_everyear majority_everyear minority_everyear dcoffice_everyear leaderofficestaff_everyear i.year if posttreat==1 & januar==0, fe cluster(stafferid)

est store modelrob2

coefplot modelrob1, bylabel(Other leaving) keep(switchtouncovered_treatment switchtocovered_treatment) ///
       || modelrob2, bylabel(Dropping staff leaving in January) keep(switchtouncovered_treatment switchtocovered_treatment) xlab(1 "Switch to uncov." 2 "Switch to cov.")  ///
       ||, drop(_cons) yline(0) vertical  ytitle("Effect estimate") ylabel(-0.04 -0.02 0 0.02 0.04) coeflabels(switchtouncovered_treatment = "Switch to uncov." switchtocovered_treatment = "Switch to cov.")

	 
coefplot (modelrob1, rename(switchtouncovered_treatment = "other") mcolor(black) ciopts(color(black))) (modelrob2, rename(switchtouncovered_treatment = "januar") mcolor(black) ciopts(color(black))),  keep(switchtouncovered_treatment) coeflabel(other  = "Other exits" januar = "Dropping staffers leaving in Jan", labsize(small)) offset(0) legend(off) drop(_cons) yline(0, lcolor(black)) vertical  ytitle("Effect estimate for switch to uncovered") ylabel(-0.04 -0.02 0 0.02 0.04) legend(off) graphregion(color(white)) title("Spurious relationship", color(black)) name(modelrob, replace)
	
	
	
*------------------------------------------------------------------------------*
* 			Controlling for size in jump of salaries and level of pay		   *
*------------------------------------------------------------------------------*	

* account for level of pay
xtreg lobbydirectafter switchtouncovered_treatment adjdaily_annualpay daysworked experience_imp experience_sq committeestaff_everyear personalstaff_everyear senate_everyear majority_everyear minority_everyear dcoffice_everyear leaderofficestaff_everyear i.year if posttreat==1, fe cluster(stafferid)
est store changesgen1

* account for change in pay
xtreg lobbydirectafter switchtouncovered_treatment salarydiff daysworked experience_imp experience_sq committeestaff_everyear personalstaff_everyear senate_everyear majority_everyear minority_everyear dcoffice_everyear leaderofficestaff_everyear i.year if posttreat==1, fe  cluster(stafferid)
est store changesgen2
	
	
*------------------------------------------------------------------------------*
*  Effect of salary decreases/increases generally and those excluding switches *
*------------------------------------------------------------------------------*		

** Othersalarydrop captures pseudo switches: from below 75% to lower

xtreg lobbydirectafter othersalarydrop daysworked experience_imp experience_sq committeestaff_everyear personalstaff_everyear senate_everyear majority_everyear minority_everyear dcoffice_everyear leaderofficestaff_everyear i.year if posttreat==1, fe cluster(stafferid)
est store changesgen3

coefplot changesgen1, bylabel(Conditioning on pay level) keep(switchtouncovered_treatment switchtocovered_treatment)  ///
       || changesgen2, bylabel(Conditioning on pay diff) keep(switchtouncovered_treatment switchtocovered_treatment) ///
	   || changesgen3, bylabel(Other salary changes) keep(switchtouncovered_treatment switchtocovered_treatment) ///
       ||, drop(_cons) yline(0) vertical  ytitle("Effect estimate") ylabel(-0.04 -0.02 0 0.02 0.04) byopts(rows(1)) coeflabels(, labsize(small))

coefplot (changesgen1, rename(switchtouncovered_treatment = "contr1") mcolor(black) ciopts(color(black))) (changesgen2, rename(switchtouncovered_treatment = "contr2") mcolor(black) ciopts(color(black))) (changesgen3, rename(othersalarydrop = "contr3") mcolor(black) ciopts(color(black))),  keep(switchtouncovered_treatment othersalarydrop) coeflabel(contr1  = "Cond. on pay level" contr2 = "Cond. on pay diff" contr3 = "Other salary drop", labsize(small)) offset(0) legend(off) drop(_cons) yline(0, lcolor(black)) vertical  ytitle("Effect estimate for switches/pay drops") ylabel(-0.04 -0.02 0 0.02 0.04) legend(off) graphregion(color(white)) title("Effects of general pay changes", color(black)) name(modelchange, replace)

graph combine modelrob modelchange, ycommon graphregion(color(white))